package com.lagou.order.controller;

import com.lagou.order.service.GoodService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author stevejson
 */
@RestController
@RequestMapping("/good")
public class GoodController {
    @Resource
    private GoodService goodService;

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public int getCount(@PathVariable(name = "id") Integer id){
        return goodService.getGood(id);
    }

    @RequestMapping(value = "/{id}", method = RequestMethod.POST)
    public Boolean createOrder(@PathVariable(name = "id") Integer id){
        return goodService.orderGood(id);
    }

    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
    public Boolean payOrder(@PathVariable(name = "id") Integer id){
        return goodService.payGood(id);
    }

}
